package model

import "gitee.com/zaiqiang231/lovesport-user-service/app/model/meta"

type TestArticle struct {
	meta.RecordModel
	Title   string    `json:"title" validate:"required" gorm:"not null;"`
	Content string    `json:"content" validate:"required" gorm:"not null;"`
	TagId   string    `json:"tag_id" validate:"required" gorm:"not null;index;"`
	Tag     TestTAG   `json:"tag" gorm:"foreignKey:TagId;references:TagId"`
	Tags    []TestTAG `gorm:"many2many:a_b"`
}

func (TestArticle) TableName() string {
	return "test_article"
}

type TestTAG struct {
	TagId    string        `gorm:"not null;unique;primary_key;"`
	TagName  string        `gorm:"unique;not null"`
	Articles []TestArticle `gorm:"many2many:a_b"`
}

func (TestTAG) TableName() string {
	return "test_tag"
}
